---
title: addAttributesToSVGElement
svgo:
  pluginId: addAttributesToSVGElement
  parameters:
    attributes:
      description: Attributes to add to the `<svg>` element. If key/value pairs are passed, the attributes are added with the paired value. If an array is passed, attributes are added with no key associated with them.
      default: null
    attribute:
---

Adds attributes to the outer most [`<svg>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg) element in the document. This is not an optimization and will increase the size of SVG documents.

:::danger

This plugin is only safe to use when a map of key/value pairs is passed. If you pass an array of keys to declare empty attributes, this will produce an malformed SVG that's only usable inline an HTML document.

:::
